package com.keepsport.keepsportapi.config;

import io.swagger.annotations.Api;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * 　　　　　   　▍ ★∴
 * 　　　．．．．▍▍．..．█▍ ☆ ★∵ ..../
 * 　　 　◥█▅▅██▅▅██▅▅▅▅▅▅▅▅▅███◤
 * 　　 　．◥███████████████◤
 * 　 ～～～～◥█████████████◤～～～～
 *
 * @author dyb
 * @create 2022-06-29 17:13
 */
@Configuration //标记这是一个配置
@EnableSwagger2 //启用Swagger
public class SwaggerConfig {
    //创建接口文档信息
    public ApiInfo createApiInfo(){
        return new ApiInfoBuilder().title("运动SM的接口文档").description("保持运动，英文名叫KeepSport简称SM，男人要保持运动！").
                contact(new Contact("顺丰快递工作室","http://www.shunfeng.com","shunfeng@163.com")).
                version("V1.0.0").build();
    }
    @Bean //IOC容器 存储  <bean>
    public Docket createApi(){
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(createApiInfo()).select().
                apis(RequestHandlerSelectors.withClassAnnotation(Api.class)).
                build();
    }
}
